{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
	<h3 class="pb-3">系统配置</h3>
	<table class="layui-table layui-table-form">
		<tr>
			<td class="layui-td-gray-2">系统名称<font>*</font>
			</td>
			<td>
				<input type="hidden" name="id" value="{$id}">
				<input type="text" name="admin_title" lay-verify="required" autocomplete="off" placeholder="请输入系统名称" lay-reqText="请输入系统名称" class="layui-input" {notempty name="$config.admin_title"} value="{$config.admin_title}"{/notempty}>
			</td>
			<td class="layui-td-gray">网站名称<font>*</font>
			</td>
			<td>
				<input type="text" name="title" lay-verify="required" autocomplete="off" placeholder="请输入网站平台名称" lay-reqText="请输入网站名称" class="layui-input" {notempty name="$config.title" } value="{$config.title}"{/notempty}>
			</td>
			<td rowspan="3" class="layui-td-gray">系统LOGO</td>
			<td rowspan="3" style="width: 240px;">
				<div class="layui-upload" style="width: 240px;">
					<div class="layui-upload-list" id="demo1" style="width: 100%; height:100px; overflow: hidden;">
						<img src='{notempty name="$config.logo"}{$config.logo}{/notempty}'
							style="max-width: 100%; width: 100%;" />
						<input type="hidden" name="logo" {notempty name="$config.logo"} value="{$config.logo}" {/notempty}>
					</div>
					<button type="button" class="layui-btn layui-btn-normal" style="width: 100%;"
						id="uploadBtn">上传LOGO</button>
				</div>
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray">网站域名</td>
			<td>
				<input type="text" name="domain" autocomplete="off" placeholder="请输入网站域名"class="layui-input" {notempty name="$config.domain" } value="{$config.domain}"{/notempty}>
			</td>
			<td class="layui-td-gray">ICP备案号</td>
			<td>
				<input type="text" name="icp" autocomplete="off" placeholder="请输入ICP备案号" class="layui-input" {notempty name="$config.icp"} value="{$config.icp}" {/notempty}>
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray-2">代码版本号</td>
			<td>
				<input type="text" name="version" autocomplete="off" placeholder="请输入版本号" class="layui-input" {notempty name="$config.version"} value="{$config.version}" {/notempty}>
			</td>
			<td class="layui-td-gray-2">公安备案号</td>
			<td>
				<input type="text" name="beian" autocomplete="off" placeholder="请输入公安备案号" class="layui-input" {notempty name="$config.beian"} value="{$config.beian}" {/notempty}>
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray">网站模板</td>
			<td>
				<select name="template">
					<option value="">请选择网站模板</option>
					{volist name="themes" id="v"}
						<option value="{$v}" {notempty name="$config.template"}{eq name="$config.template" value="$v"}selected{/eq}{/notempty}>{$v}</option>
					{/volist}
				</select>
			</td>
			<td class="layui-td-gray">验证码发送</td>
			<td>
				<select name="send_captcha">
					<option value="">请选择验证码类型</option>
					<option value="2" {notempty name="$config.send_captcha"}{eq name="$config.send_captcha" value="2"}selected{/eq}{/notempty}>阿里云短信</option>
				</select>
			</td>
			<td class="layui-td-gray">上传方式</td>
			<td>
				<select name="upload_driver">
					<option value="">请选择上传方式</option>
					<option value="1" {notempty name="$config.upload_driver"}{eq name="$config.upload_driver" value="1"}selected{/eq}{/notempty}>本地上传</option>
					<option value="2" {notempty name="$config.upload_driver"}{eq name="$config.upload_driver" value="2"}selected{/eq}{/notempty}>阿里云OSS</option>
				</select>
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray">SEO关键词</td>
			<td colspan="5">
				<input type="text" name="keywords" autocomplete="off" placeholder="多个关键词用“,”隔开" class="layui-input" {notempty name="$config.keywords"} value="{$config.keywords}"{/notempty}>
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray">SEO描述</td>
			<td colspan="5">
				<textarea name="desc" placeholder="请输入网站描述" class="layui-textarea">{notempty name="$config.desc"}{$config.desc}{/notempty}</textarea>
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray">统计代码</td>
			<td colspan="5">
				<textarea name="code" placeholder="请输入完整的统计代码" class="layui-textarea">{notempty name="$config.code"}{$config.code}{/notempty}</textarea>
			</td>
		</tr>		
		<tr>
			<td class="layui-td-gray">版权信息</td>
			<td colspan="5">
				<textarea name="copyright" placeholder="请输入版权信息" class="layui-textarea">{notempty name="$config.copyright"}{$config.copyright}{/notempty}</textarea>
			</td>
		</tr>
	</table>

	<div class="py-3">
		<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
		<button type="reset" class="layui-btn layui-btn-primary">重置</button>
	</div>
</form>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
	const moduleInit = ['tool'];
	function feiniaoInit() {
		var form = layui.form, tool = layui.tool, upload = layui.upload;
		//监听提交
		form.on('submit(webform)', function (data) {
			let callback = function (e) {
				layer.msg(e.msg);
				if (e.code == 0) {
					parent.layui.tool.close(1000);
				}
			}
			tool.post("{:url('conf/edit')}", data.field, callback);
			return false;
		});

		//logo上传
		var uploadInst = upload.render({
			elem: '#uploadBtn',
			url: "{:url('api/upload')}",
			done: function (res) {
				if (res.code == 1) {
					layer.msg('上传失败');
				} else {
					layer.msg('上传成功');
					$('#demo1 input').attr('value', res.data.filepath);
					$('#demo1 img').attr('src', res.data.filepath);
				}
			}
		});
	}
</script>
{/block}
<!-- /脚本 -->